Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NIR <> snnTorch #246

Merged
merged 34 commits into from
Feb 5, 2024
Merged

Update NIR <> snnTorch #246

merged 34 commits into from
Feb 5, 2024

Conversation

stevenabreu7
Copy link
Collaborator

@stevenabreu7 stevenabreu7 commented Oct 9, 2023

This PR will:

  • add import functionality from NIR to snnTorch.
  • add NIR import/export support for RNNs

For RNNs to work, make sure to use the right version of NIRTorch (current PR: neuromorphs/NIRTorch#12)

@stevenabreu7 stevenabreu7 changed the title Update NIR support Import from NIR to snnTorch Oct 10, 2023
@stevenabreu7 stevenabreu7 changed the title Import from NIR to snnTorch Update NIR <> snnTorch Oct 10, 2023
@stevenabreu7 stevenabreu7 marked this pull request as ready for review January 27, 2024 01:23
@stevenabreu7
Copy link
Collaborator Author

after some (way too much) time, this PR is ready for review! @jeshraghian @ahenkes1 can you advise on next steps? add tests? docs? how can I help? cheers!

@@ -141,6 +141,7 @@ def __init__(
output=False,
graded_spikes_factor=1.0,
learn_graded_spikes_factor=False,
reset_delay=True,
Copy link
Collaborator Author

@stevenabreu7 stevenabreu7 Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a clarifying comment: @jeshraghian and I discussed this a while ago - this flag is needed to match up the neuron dynamics with NIR. (with the default value, snntorch will behave exactly as before)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version of the Leaky neuron had some minor refactoring to get it compatible with torch.compile(), so there will be some conflicts. I'll iron these out today.

@jeshraghian
Copy link
Owner

This is wonderful, thanks @stevenabreu7 !

docs

In terms of docs, we should generate docstrings that describe the arguments of those two import/export functions with a minimalist example.

Any caveats can be added as bullet points in the docstrings, e.g., types of neurons supported, layers, neuron arguments supported.

I can create a skeleton, though would you be able to fill the meat?

Once we have that, I can also put together some ipynb stuff based on these docstrings.

tests
It'd be worth adding a test for our leaky neurons when the reset_delay is active. I can handle this.

I'm not too sure how we can do unit tests for the actual nir-dependent stuff, though... any ideas? Could it be a matter of having a minimalist set of models, passing them in, making sure their outputs have the arguments (just an assertion the arguments exist. Checking its values is overkill and left to nir). Thoughts?

@stevenabreu7
Copy link
Collaborator Author

sounds good! I added docstrings, lmk if they're okay like that. Also added suggestions for how to test in test_nir.py, what do you think? if you're okay with it, I'll fill in the rest @jeshraghian

@jeshraghian
Copy link
Owner

Alright, looking great @stevenabreu7!

Some of the syntax from the leaky neuron was modified in another PR to make it compatible with torch.compile() so there were a few conflicts + failing tests that I've now fixed and pushed to your branch.

Your suggestions for tests look great, as do the docstrings.
Once the tests are done then it's good to merge.

@stevenabreu7
Copy link
Collaborator Author

thank you @jeshraghian! added test and some notes on the rleaky that's not currently supported. I can make a new PR for this, wouldn't take long, but can we merge already so that it runs smoothly for the NIR demo tomorrow? (otherwise it's a bit of a pain to use this branch of snntorch for the demo)

@stevenabreu7
Copy link
Collaborator Author

added an issue for RLeaky support - will update the NIR support in a fresh PR in the near future

@jeshraghian jeshraghian merged commit 70b1c65 into jeshraghian:master Feb 5, 2024
4 checks passed
@jeshraghian
Copy link
Owner

Just merged! The demo will still need to be from the latest version that is installed from the source rather than pip installing. Though I can do a version increment in the morning, if that helps. Lmk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants